import { request } from "@/utils";

interface Repass {
  id: string;
  password: string;
}
interface Assign {
  userId: string;
  roleIds: string[];
}
export const sysUserApi = {
  getUser: () => request.get<User>("/sys-user"),
  getRoute: () => request.get<AuthRoute.Route[]>("/sys-user/route"),
  add: (data: User) => request.post("/sys-user", data),
  getList: () => request.get<User[]>("/sys-user/list"),
  remove: (id: string) => request.delete("/sys-user", { id }),
  update: (data: User) => request.put("/sys-user", data),
  repass: (data: Repass) => request.put("/sys-user/repass", data),
  getRolesIdById: (id: string) =>
    request.get("/sys-user/getRolesIdById", { id }),
  assign: (data: Assign) => request.post("/sys-user/assign", data),

  updateBasic: (data: User) => request.put("/sys-user/update/basicInfo", data),
  /** 返回头像远程url */
  updateAvatar: (data: FormData) =>
    request.put<string>("/sys-user/update/avatar", data, {
      headers: { "Content-Type": "multipart/form-data" },
    }),
};
